Skip to content

@Bindable for observable models - #28

Merged
colemancda merged 4 commits into
masterfrom
feature/bindable
Jul 23, 2026
Merged

@Bindable for observable models#28
colemancda merged 4 commits into
masterfrom
feature/bindable

Conversation

@colemancda

Copy link
Copy Markdown
Member

Third parity tier: @Bindable. Closes the two-way-binding hole for @Observable models — $model.property now projects a Binding into a reference type, so a bound control writes straight through to the model and its observation drives re-evaluation.

What's new

  • @Bindable property wrapper (@dynamicMemberLookup) wrapping a reference; $model.property yields a Binding<Property> backed by a ReferenceWritableKeyPath (writes through the object without reassigning it).

Purely Swift-side sugar — no interpreter changes. Bound TextField/Toggle/Slider already accept a Binding, so a binding from $model.name is indistinguishable from one from @State.

Verification

  • swift test — 2 new tests (projection + a TextField bound via $model.name writing back through the model), 41 total passing
  • Emulator (new Bindable screen): typing the field, toggling, and dragging the slider all mutate one shared @Observable model, and the sibling Text views re-render from it

@colemancda
colemancda merged commit c420831 into master Jul 23, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant